home *** CD-ROM | disk | FTP | other *** search
- #include "Patches.h"
-
- #include <osutils.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- long BGetTrapAddress(short trap,short tType)
- {
- if(tType == ToolTrap){
- return (long)GetToolTrapAddress(trap);
- }else{
- return (long)GetOSTrapAddress(trap);
- }
- }
-
- void BSetTrapAddress(long proc,short trap,short tType)
- {
- if(tType == ToolTrap){
- SetToolTrapAddress((UniversalProcPtr)proc,trap);
- }else{
- SetOSTrapAddress((UniversalProcPtr)proc,trap);
- }
- }
-
- static TrapType GetTrapType(short tTrap)
- {
- const short trapMask = 0x0800;
-
- if ((tTrap & trapMask) == trapMask)
- return(ToolTrap);
- else
- return(OSTrap);
- }
-
-
- long BGetTrapAddress1(short trapWord)
- {
- return BGetTrapAddress(trapWord,GetTrapType(trapWord));
- }
-
- void BSetTrapAddress1(long proc,short trapWord)
- {
- BSetTrapAddress(proc,trapWord,GetTrapType(trapWord));
- }
-
-
- void PatchTrapSafe(short trap,long newProc,long *oldProc)
- {
- TrapType tType = GetTrapType(trap);
-
- *oldProc = BGetTrapAddress(trap,tType);
- BSetTrapAddress(newProc,trap,tType);
- }
-
- long PatchTrap(short trap,long newProc)
- {
- long oldTrap;
- TrapType tType = GetTrapType(trap);
-
- oldTrap = BGetTrapAddress(trap,tType);
- BSetTrapAddress(newProc,trap,tType);
-
- return oldTrap;
- }
-
- #ifdef __cplusplus
- }
- #endif
-
-